package com.lxj.controller;

import com.lxj.domain.Teacher;
import com.lxj.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@ResponseBody
@RequestMapping("/teacher")
@Controller
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @PostMapping("/selectAll")
    public Map<String, Object> selectAll(Teacher teacher) {
        List<Teacher> list = teacherService.selectAll(teacher);
        int number = teacherService.getNumber();
        Map<String,Object> map = new HashMap<>();
        map.put("list",list);
        map.put("number",number);
        return map;
    }
    @PostMapping("/selectClassTeacher")
    public Map<String, Object> findAll(Teacher teacher) {
        List<Teacher> list = teacherService.findAll(teacher);
        int number = teacherService.getCount();
        Map<String,Object> map = new HashMap<>();
        map.put("list",list);
        map.put("number",number);
        return map;
    }
    @GetMapping("/delete")
    public int delete(Integer[] id) {
        return teacherService.delete(id);
    }
    @GetMapping("/deleteClassTeacher")
    public int deleteClassTeacher(Integer[] id) {
        return teacherService.deleteClassTeacher(id);
    }
}
